# 定义工厂函数第一步设置默认配置
class DefaultConfig:
    """默认配置"""
    # mysql配置
    SQLALCHEMY_DATABASE_URI = 'mysql://root:mysql@192.168.19.137:3306/hm_topnews'  # 连接地址
    SQLALCHEMY_TRACK_MODIFICATIONS = False  # 是否追踪数据变化
    SQLALCHEMY_ECHO = False  # 是否打印底层执行的SQL
    # 主从数据库的URI
    # SQLALCHEMY_DATABASE_URI 建议保留,建表使用该配置
    # SQLALCHEMY_BINDS 增删改查使用该配置
    SQLALCHEMY_BINDS = {
        "master": 'mysql://root:mysql@192.168.19.137:3306/hm_topnews',
        "slave1": 'mysql://root:mysql@192.168.19.137:3306/hm_topnews',
        "slave2": 'mysql://root:mysql@192.168.19.137:8306/hm_topnews'
    }

    # redis配置
    # REDIS_HOST = '192.168.19.137'  # ip
    # REDIS_PORT = 6381  # 端口
    # redis集群配置
    CLUSTER_NODES = [  # 集群中主数据库的ip和端口号
        {'host': '192.168.19.137', 'port': 7000},
        {'host': '192.168.19.137', 'port': 7001},
        {'host': '192.168.19.137', 'port': 7002},
    ]

    # JWT
    JWT_SECRET = 'TPmi4aLWRbyVq8zu9v82dWYW17/z+UvRnYTt4P6fAXA'  # 秘钥
    JWT_EXPIRE_DAYS = 14  # JWT过期时间

    # 七牛云
    QINIU_ACCESS_KEY = 'kJ8wVO7lmFGsdvtI5M7eQDEJ1eT3Vrygb4SmR00E'
    QINIU_SECRET_KEY = 'rGwHyAvnlLK7rU4htRpNYzpuz0OHJKzX2O1LWTNl'
    QINIU_BUCKET_NAME = 'sh35'
    QINIU_DOMAIN = 'http://q7f6ieukf.bkt.clouddn.com/'

    # cors跨域也可以在配置文件中指定要限制的域名
    # CORS_ORIGINS = ['http://127.0.0.1:5000']  # 限定允许访问的域名,不设置则全部允许

    # 设置哨兵的ip和端口
    SENTINEL_LIST = [
        ('192.168.19.137', 26380),
        ('192.168.19.137', 26381),
        ('192.168.19.137', 26382),
    ]

    SERVICE_NAME = 'mymaster'  # 哨兵配置的主数据库别名


# 定义字典记录配置类型和配置子类之间的映射关系
config_dict = {
    'dev': DefaultConfig
}
